<template>
	<div class="page">
		<div class="title-content">
			<div class="search">
				<i class="iconfont icon-sousuo"></i>
				<mt-field label="" placeholder="商品名称" v-model="searchValue"></mt-field>
			</div>
		</div>
		<div class="table-view" v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="10">
		   <li class="cell" v-for="(item,index) in items" @click="goJoin(item.pk_id)">
		  	<!--<router-link :to="{name:'fc-detail',params:{id:item.pk_id}}">-->
		  		<div class="img-content">
			  		<img :src="item.image" />
			  		<!--<div style="position: absolute;bottom: 0px;background-color: rgb(0,199,102);color: white;width: 100%;text-align: center;padding: 3px;">推荐消费成功后返红包{{item.recommend_integral}}元</div>-->
			  	</div>
			  	<div class="desc-content">
			  		<div class="desc">{{item.product_name != null?item.product_name:'暂无商品名称'}}</div>
			  		<div class="price">款号：{{item.goods_no}}</div>
			  		<div class="price">价格：￥{{item.sale_price}}
			  		</div>
			  		<!--<div class="time single-line">{{item.gater_content}}</div>-->
			  		<!--<div class="time">
			  			<label>{{item.count}}人已参加</label>
			  			<div >
			  				<count-down class="count-time" v-on:start_callback="countDownS_cb(1)" v-on:end_callback="countDownE_cb(1)" :currentTime="item.currentTime" :startTime="item.currentTime" :endTime="item.end_time" :tipText="'距离开始文字'" :tipTextEnd="'距离结束文字1'" :endText="'活动已结束'" :dayTxt="'天'" :hourTxt="'时'" :minutesTxt="'分'" :secondsTxt="'秒'"></count-down>
			  			</div>
			  		</div>-->
			  	</div>
		  	<!--</router-link>-->
		  </li>
		</div>
		<!--<div class="page-header">时尚评点</div>-->
	</div>
</template>

<style scoped>
	@import url("index.css"); 
	@import url("../../common/common.css");
</style> 

<script>
	import $ from 'jquery'
    export default {
        name: "index",
        data:function(){
        		return {
        			items:[],
        			pageNo:0,
        			loading:false,
        			searchValue:'',
        			searching:false
        		};
        },
        created(){
        		document.title = '商品浏览';
        		console.log(this.$route.params)
        },
        methods:{
        		loadMore() {
			  this.loading = true;
			  this.searching = false;
			  if(this.pageNo == 0){
			  	this.items = [];
			  }
			  this.pageNo++;
			  var _self = this;
 			  this.$Spin.show();
			  $.ajax({
			  	type:"post",
			  	contentType:'application/json;charset=UTF-8',
			  	url:this.utils.rootUrl + "fashion/list?pageSize=10&pageNo="+_self.pageNo,
			  	data:JSON.stringify({
			  		type:'comment',
			  		searchValue:_self.searchValue,
			  		goodsType:this.$route.params.type
			  	}),
			  	success:function(res){
					_self.$Spin.hide();
					_self.loading = false;
			  		var dataList = res.dataList;
			  		if(dataList.length == 0){
			  			_self.loading = true;
			  			return;
			  		}
			  		for(var i in dataList){
			  			_self.items.push(dataList[i]);
			  		}
			  	},
			  	error:function(e){
			  		_self.$Spin.hide();
			  	}
			  });
			},
			goJoin(id){
				this.$router.push({ path: '/fashion/fc-detail/'+id+"/"+this.utils.getQueryString('openId')})
			}
        },
        watch:{
        		searchValue(curVal,oldVal){
        			var _self = this;
        			if(!_self.searching){
        				_self.searching = true;
        				setTimeout(function(){
	        				_self.pageNo = 0;
	        				_self.loadMore();
	        			},2000)
        			}
        		}
        },
        filters: {
	        formatDate(time) {
	            return new Date(parseInt(time)).toISOString().substr(0,10);
	        }
	    },
	    deactivated(){
	    		this.loading = true;
	    },
    //修改列表页的meta值，false时再次进入页面会重新请求数据。  
	    beforeRouteLeave(to, from, next) {  
	        from.meta.keepAlive = true; 
	        to.meta.keepAlive = false;
	        next();  
	    } 
    }
</script>


